home *** CD-ROM | disk | FTP | other *** search
/ MacHome 2001 June / MacHome Magazine Demo Disc June 2001.iso / Stuff / Software / Graphic / iView PhotoMover 2.0.3 / AppleScript samples / Photomover / FotoTime set Album w debug < prev    next >
Encoding:
Text File  |  2001-04-10  |  4.4 KB  |  158 lines  |  [TEXT/ToyS]

  1. global theCount
  2. global aRecord
  3. global i
  4.  
  5.  
  6. -- set appMoverName to "iView PhotoMover"
  7.  
  8. on run
  9.     set this_app to the path to frontmost application as string
  10.     tell me to activate
  11.     
  12.     if AboutScript() = "Cancel" then
  13.         tell application this_app to activate
  14.         return -- show about
  15.     end if
  16.     set aRecord to {}
  17.     set i to 1
  18.     
  19.     tell application "MacOS Toolbox DEBUG PPC"
  20.         activate -- file to uploading bring to fround... afile
  21.         
  22.         set klog to get the Log -- Save current settings
  23.         set ksound to get the Sound
  24.         set kdetails to get the Details
  25.         set khost to get the Host
  26.         
  27.         --set the Details to true -- Set Details to true for tracking down problems.
  28.         set the Details to true
  29.         set the Log to true -- save  result to log file...
  30.         set the Sound to false -- save  result to log file...
  31.         
  32.         -- Host ID's.
  33.         -- 0 = PhotoPoint 
  34.         -- 1 = ClubPhoto -- supports Picture Description and Album Selection (V2.0) / creation (V2.02)
  35.         -- 2 = zing
  36.         -- 3 = ImageStation
  37.         -- 4 = NikonNet
  38.         -- 5 = FotoTime  -- supports Picture Description and Album Selection (V2.0) / creation (V2.02)
  39.         set the Host to 5
  40.         
  41.     end tell
  42.     
  43.     -- get and sort only the photos with an exposure date
  44.     tell application "iView MediaPro"
  45.         
  46.         if not (exists window 1) then
  47.             beep
  48.             tell me to activate
  49.             display dialog "No catalogs are open!  Try again." buttons {"Oops..."} default button 1 with icon stop
  50.             tell application this_app to activate
  51.             return
  52.         end if
  53.         
  54.         tell window 1
  55.             copy (count objects) to theCount
  56.             if theCount = 0 then
  57.                 beep
  58.                 tell me to activate
  59.                 display dialog "No items visible in catalog!  Try again." buttons {"Oops..."} default button 1 with icon stop
  60.                 tell application this_app to activate
  61.                 return
  62.             end if
  63.             
  64.             try
  65.                 -- Process all selected items...
  66.                 repeat with i from 1 to theCount
  67.                     
  68.                     -------------------------------------
  69.                     -- Get file details
  70.                     set fileName to (name of object i) -- Get for reporting errors.
  71.                     set theCap to (caption of object i) -- Set theCap to the FileName.
  72.                     
  73.                     set theCountry to (country of object i)
  74.                     set theState to (state of object i)
  75.                     set theCity to (city of object i)
  76.                     
  77.                     -- logic to remove black cities and states.
  78.                     if theState = "" then
  79.                         if theCity = "" then
  80.                             set theAlbum to theCountry
  81.                         else
  82.                             set theAlbum to theCountry & " - " & theCity
  83.                         end if
  84.                     else
  85.                         if theCity = "" then
  86.                             set theAlbum to theCountry & " - " & theState
  87.                         else
  88.                             set theAlbum to theCountry & " - " & theState & " - " & theCity
  89.                         end if
  90.                     end if
  91.                     
  92.                     set AppleScript's text item delimiters to ", "
  93.                     -- Also include keywords, by removing the two '--' fields
  94.                     -- set theKeywords to (keywords of object i)
  95.                     -- set theCap to theCap & return & "Keywords: " & theKeywords as text
  96.                     --------------------------------------
  97.                     
  98.                     if the mounted of object i = true then -- only do mount items
  99.                         
  100.                         set afile to (path of object i) as alias
  101.                         
  102.                         tell application "MacOS Toolbox DEBUG PPC"
  103.                             
  104.                             try
  105.                                 --  set timeout to some large number
  106.                                 with timeout of 3600 seconds -- how long to upload? 1 hour?
  107.                                     
  108.                                     -- upload the image to the current site.
  109.                                     open afile into album theAlbum with description theCap
  110.                                     
  111.                                 end timeout
  112.                                 
  113.                             on error msg number n
  114.                                 tell me to activate
  115.                                 display dialog msg & "( " & n & " )" & return & ¬
  116.                                     "Uploading " & return & "File: " & fileName
  117.                                 exit repeat
  118.                             end try
  119.                             
  120.                         end tell -- PhotoMover
  121.                     end if -- mounted
  122.                     --    set (caption of object (aName as integer)) to newCap
  123.                 end repeat
  124.                 
  125.             on error err_msg
  126.                 beep
  127.                 tell me to activate
  128.                 display dialog err_msg & return & "getting info.." & return & "File: " & fileName
  129.             end try
  130.             
  131.         end tell -- Window 1
  132.         
  133.     end tell
  134.     
  135.     tell application "MacOS Toolbox DEBUG PPC"
  136.         set the Log to klog -- restore the settings
  137.         set the Sound to ksound
  138.         set the Details to kdetails
  139.         set the Host to khost
  140.     end tell
  141.     tell me to activate
  142.     
  143.     beep
  144.     display dialog "Finished uploading." with icon note buttons {"Thanx"} default button 1
  145.     tell application this_app to activate
  146. end run
  147.  
  148. -- about this script
  149. on AboutScript()
  150.     display dialog ¬
  151.         "About \"FotoTime PhotoMover Upload script\"" & return & return & ¬
  152.         "Upload catalog items with file name as the caption to FotoTime." & return & return ¬
  153.         with icon note
  154.     set theAnswer to the button returned of the result
  155.     return theAnswer
  156. end AboutScript
  157.  
  158.